package com.leyou.search.dto;

import java.util.Map;

public class SearchRequest {
    private String key;//搜索条件

    private Integer page;//当前页

    private Map<String,String> filters;

    private static final Integer DEFAULT_SIZE = 20;//每页大小，不从页面接收，而是固定大小

    private static final Integer DEFAULT_PAGE = 1;//默认页

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        if (page == null) {
          return DEFAULT_PAGE;
        }
        //获取页码时做一些校验，不能小于1
        return Math.max(DEFAULT_PAGE,page);
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Map<String, String> getFilters() {
        return filters;
    }

    public void setFilters(Map<String, String> filters) {
        this.filters = filters;
    }

    public static Integer getDefaultSize() {
        return DEFAULT_SIZE;
    }

    public static Integer getDefaultPage() {
        return DEFAULT_PAGE;
    }

    public Integer getSize(){
        return DEFAULT_SIZE;
    }
}

